home *** CD-ROM | disk | FTP | other *** search
- /* Copyright (c) 1988 Bellcore
- * All Rights Reserved
- * Permission is granted to copy or use this program, EXCEPT that it
- * may not be sold for profit, the copyright notice must be reproduced
- * on copies, and credit should be given to Bellcore where it is due.
- * BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
- */
- /* $Header: icontoc.c,v 4.2 88/07/11 10:12:56 sau Exp $
- $Source: /tmp/mgrsrc/demo/icon/RCS/icontoc.c,v $
- */
- static char RCSid_[] = "$Source: /tmp/mgrsrc/demo/icon/RCS/icontoc.c,v $$Revision: 4.2 $";
-
- /* comnvert mgr icon to "c" */
-
-
- static char *cmd;
-
- #include <stdio.h>
- #include "bitmap.h"
-
- main(argc,argv)
- int argc;
- char **argv;
- {
-
- cmd = *argv;
- argv++; argc--;
- if (argc < 1)
- usage();
-
- /*
- if( EQ( *argv, "-a" ) ) {
- if( argc >= 2 )
- usage();
- argv++; argc--;
- align = atoi( *argv );
- argv++; argc--;
- }
- */
-
- if( argc < 1 )
- usage();
-
- for( ; argc > 0; argv++, argc-- )
- dofile( *argv );
-
- exit(0);
- }
-
-
- static
- dofile( filename )
- char *filename;
- {
- FILE *filep;
- register unsigned char *cp, *endp;
- register int i;
- BITMAP *map, *bitmapread();
- char *name;
- char *rindex();
-
- if ((filep = fopen(filename,"r")) == NULL) {
- fprintf(stderr,"%s: Can\'t open %s\n",cmd,filename);
- exit(2);
- }
-
- if( !(map = bitmapread( filep )) ) {
- fprintf(stderr,"%s: %s is not a bitmap file\n",cmd,filename);
- fclose(filep);
- exit(3);
- }
- fclose(filep);
-
- /* print out header */
-
- if (name = rindex(filename,'/'))
- name++;
- else
- name = filename;
-
- printf("\
- \n/* bitmap for \"%s\", %d wide, %d high, %d bit%s deep, %d bit aligned\n\
- */\n",
- name, BIT_WIDE(map), BIT_HIGH(map),
- BIT_DEPTH(map), BIT_DEPTH(map) > 1 ? "s" : "", BITS+1);
-
- printf("bit_static(%s, %d, %d, %s_data, 1);\n", name,
- BIT_WIDE(map), BIT_HIGH(map), name);
-
- /* print out data */
-
- cp = (unsigned char *)BIT_DATA(map);
- endp = cp + BIT_SIZE(map);
- printf("char %s_data[%d] = {\n\t", name, endp - cp);
- for( i=1; cp < endp; cp++, i++ )
- printf("0%3.3o%s", *cp, i%10 ? ", " : ",\n\t");
- printf("\n\t};\n");
- free((char*)map);
- }
-
- static
- usage()
- {
- fprintf( stderr,"Usage: %s <icon_file> ... > <icon>.c\n", cmd );
- /*
- fputs( "\
- -a n Create bit map aligned to n bits. n may be 8, 16, or 32.\n", stderr );
- */
- exit(1);
- }
-